﻿// *************************************************************************************************
// Project: RealSense.Light.Extensions
// Namespace: RealSense.Light.Extensions
// File: designtimesupport.cs  Author: Peter O'Hanlon
// Copyright © Peter O'Hanlon 2014-2015
// Date: 2015/1/13 21:20
// *************************************************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace RealSense.Light.Extensions
{
  /// <summary>
  /// Provide the ability to exclude certain functionality from running because
  /// the application is inside the designer. This helps to prevent issues when
  /// we want to view items containing our functionality inside the XAML design
  /// window.
  /// </summary>
  public static class DesignTimeSupport
  {
    private static bool? isInDesigner;

    /// <summary>
    /// Gets whether or not the application is currently "running" inside
    /// the Designer.
    /// </summary>
    public static bool IsInDesigner
    {
      get
      {
        if (!isInDesigner.HasValue)
        {
          isInDesigner = (bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(
            typeof(DependencyObject)).DefaultValue;
        }
        return isInDesigner.Value;
      }
    }
  }
}
